Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Restrict general help content in REPL context #5885

Merged
merged 11 commits into from
Feb 16, 2023
Merged

Restrict general help content in REPL context #5885

merged 11 commits into from
Feb 16, 2023

Conversation

cds-amal
Copy link
Member

@cds-amal cds-amal commented Feb 11, 2023

PR description

This PR limits the general help output for truffle console and truffle develop so help for console, dashboard, db, develop, init and watch won't be shown. It achieves this by defining a single source of truth for valid CLI and Console commands. The commands/commands.js module defines this state, and other parts of the codebase have been refactored to import and rely on this information. The Console class no longer needs to be passed allowedCommands and has removed the maintenance of excludedCommands. Instead, the signature for the help function has changed to indicate whether it is displaying help for the CLI or the REPL. Tests and webpack concerns have been updated to reflect these changes, and the source of truth for valid Truffle commands has been updated in various files.

Contributes to: #5312

Testing instructions

  • Try help in truffle develop, and confirm it doesn't show help for console, dashboard, db, develop, init and watch
  • Verify help isn't broken :/

Documentation & breaking changes concerns

  • No docs required.
  • Error text changed in REPL output, so it's arguable this might be a breaking change. Thoughts?

@cds-amal cds-amal marked this pull request as ready for review February 12, 2023 14:02

// Create an expression that returns a string when evaluated
// by the REPL
const makeIIFE = str => `(() => "${str}")()`;

const processInput = (input, allowedCommands) => {
const processInput = input => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working this PR I was tempted to refactor REPL input processing because it is all over the place, misnamed and should be consolidated. I'll add an issue for that.

@cds-amal cds-amal changed the title Remove invalid commands from REPL general help command Restrict general help content in REPL context Feb 12, 2023
@haltman-at
Copy link
Contributor

  • Error text changed in REPL output, so it's arguable this might be a breaking change. Thoughts?

I have to say I don't see how that's a breaking change.

packages/core/lib/command-utils.js Show resolved Hide resolved
packages/core/lib/commands/commands.js Outdated Show resolved Hide resolved
packages/core/lib/console.js Outdated Show resolved Hide resolved
packages/truffle/test/scenarios/commands/develop.js Outdated Show resolved Hide resolved
Copy link
Contributor

@haltman-at haltman-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. What was that getCommand doing there, I wonder? (Actually, I'd bet it was the older code and then the guard was later added before it. Hm... did the guard break using abbreviated commands at the console? Oh well, nobody's complained about it...)

@cds-amal cds-amal merged commit 591d3ac into develop Feb 16, 2023
@cds-amal cds-amal deleted the help-less branch February 16, 2023 03:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants